import request from "../../../../assets/js/request";

/**
 * 获取字典表中的用户类型
 * @returns {*}
 */
export function getUserType(tableName,fieldName) {
  return request({
    url: '/dictionary/getUserType',
    method: 'GET',
    params:{
      tableName:tableName,
      fieldName:fieldName
    },
    headers:{
      "Content-Type": "application/json",
    }
  })
}

/**
 * 修改用户类型名称
 * @param typeName
 * @returns {Promise<AxiosResponse<any>> | *}
 */
export function changeTypeName(id,typeName){
  return request({
    url: '/dictionary/changeTypeName',
    method: 'get',
    params: {
      id: id,
      typeName:typeName
    },
    headers:{
      "Content-Type" : "application/json"
    }
  })
}

/**
 * 修改类型状态
 * @param id
 * @param status
 * @returns {Promise<AxiosResponse<any>> | *}
 */
export function updateStatus(id,status){
  return request({
    url : '/dictionary/updateStatus',
    method: 'get',
    params:{
      id : id,
      status : status
    },
    headers:{
      "Content-Type" : "application/json"
    }
  })
}

/**
 * 删除用户类型
 * @param id
 * @returns {Promise<AxiosResponse<any>> | *}
 */
export function deleteType(id){
  return request({
    url : '/dictionary/deleteData',
    method: 'delete',
    params:{
      id: id
    },
    headers:{
      "Content-Type" : "application/json"
    }
  })
}

/**
 * 添加用户类型
 * @param typeName
 * @returns {Promise<AxiosResponse<any>> | *}
 */
export function addUserType(typeName){
  console.log(typeName)
  return request({
    url : '/dictionary/addUserType',
    method: 'get',
    params:{
      typeName : typeName
    },
    headers:{
      "Content-Type" : "application/json"
    }
  })
}
